﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UAgentMacStockDetailAdd : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }
        protected override string DWZRef
        {
            get { return "UAgentMacStockList"; }
        }

        #region
        protected int UASID
        {
            get
            {
                return GetRequestValue<int>("UASID",0);
            }
        }

        protected UAgentMacStockInfo _obj = null;
        protected UAgentMacStockInfo obj
        {
            get
            {
                if (_obj == null)
                {
                    _obj = UAgentMacStockController.GetById(UASID);
                }
                return _obj;
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();
                
            }

            BindDate();
        }

        protected void addmenu()
        {
            UAgentMacStockDetailInfo obj = Request.SerializableObject<UAgentMacStockDetailInfo>();
            obj.RealName = GetRequestValue<string>("dwz.orgLookup.RealName", "");
            //obj.AgentName = GetRequestValue<string>("dwz_orgLookup.AgentName", "");
            this.AddLog(Permission.新增, obj);
            if (UAgentMacStockController.UAgentMacStockDetail_Add(obj))
                SuccessAlertJson("成功添加定检记录");
            else
                ErrorJson("添加定检记录失败");
        }

        protected string GetCheckLabel()
        {
            string reurnhtml = "";
            string optiontemp = "<option value=\"{0}\">{0}&nbsp;&nbsp;&nbsp;&nbsp;</option>";
            for (int i = 1; i <= 50; i++)
            {
                reurnhtml += string.Format(optiontemp, "定检" + i.ToString());
            }
            return reurnhtml;
        }

        protected void BindDate()
        {

            this.rpMenu.DataSource = UAgentMacStockController.UAgentMacStockDetail_GetALLByUASID(UASID);
            this.rpMenu.DataBind();
        }
    }
}